<template>
    <div>
        <Row :gutter="10">
            <Col span="24">
            <Card class="slideList">
                <p slot="title" style="height: 26px">
                    <Icon type="ios-albums-outline"></Icon>
                    礼物赠送记录表
                </p>
                <div class="edittable-table-height-con">
                    <Table :columns="slideTableHead" :data="gifthisList" border :no-filtered-data-text="tipeNews" :no-data-text="tipeNews" ref="slideTableHead"></Table>
                </div>
            </Card>
            </Col>
        </Row>
        <Page :total="total" :current="page" :page-size="pageSize" @on-change="onCurrentChange" style="text-align: center"></Page>
    </div>
</template>
<script>
    export default {
        data () {
            return {
                //表头
                slideTableHead:[
                    {
                        title: '赠送人昵称',
                        align: 'center',
                        key: 'fromName',
                    },
                    {
                        title: '赠送人编号',
                        align: 'center',
                        key: 'fromId',
                        "sortable": true,
                    },
                    {
                        title: '礼物名字',
                        align: 'center',
                        key: 'name',
                    },
                    {
                        title: '金币',
                        align: 'center',
                        key: 'glod',
                    },
                    {
                        title:'礼物图标',
                        width:"70px",
                        align: 'center',
                        className:'icon',
                        render: (h, params) => {
                            const row = params.row;
                            const icon = row.icon;
                            return h('img', {
                                attrs: {
                                    src:icon,
                                },
                                style:{
                                    width:"50px",
                                    height:'50px'
                                }
                            });
                        }
                    },
                    {
                        title: '主播ID',
                        align: 'center',
                        key: 'anchorId',
                        "sortable": true,
                    },
                    {
                        title: '主播昵称',
                        align: 'center',
                        key: 'toName',
                    },
                    {
                        title: '增数量',
                        align: 'center',
                        key: 'number',
                    },
                    {
                        title: '直播间ID',
                        align: 'center',
                        key: 'liveId',
                    },
                    {
                        title: '赠送时间',
                        align: 'center',
                        key: 'sendTime',
                    },


                ],
                selectURl:'/gifthis/list',
                gifthisList:[],
                tipeNews:'暂无数据',
                total:0,
                pageSize:0,
                page:1,
            }
        },
        created () {
            this.getData();
        },
        methods: {
            //初始化时获取数据
            getData () {
                let self = this;
                debugger;
                self.$axios.get(self.selectURl + '?curr=' + self.page).then((res) => {
                    for (var i = 0; i < res.data.data.rows.length; i++) {
                        let time = new Date(res.data.data.rows[i].sendTime).toLocaleString();
                        res.data.data.rows[i].sendTime = time;
                    }
                    self.gifthisList = res.data.data.rows;
                    self.page = res.data.data.page;
                    self.pageSize = res.data.data.pagesize;
                    self.total = res.data.data.total;
                })
            },
            onCurrentChange(val){
                let self = this;
                self.page = val;
                self.getData();
            }
        }
    }
</script>